// 冒泡排序

/**
 * @param {Array} list 排序数组
 * @param {string} type 升序降序 asc升序 desc降序
 * */
export default function (list, type = 'asc') {
    list.map(() => {
        list.map((_, index) => {
            if (type == 'asc') {
                if (list[index] > list[index + 1]) {
                    [list[index], list[index + 1]] = [list[index + 1], list[index]]
                }
            } else if (type == 'desc') {
                if (list[index] < list[index + 1]) {
                    [list[index], list[index + 1]] = [list[index + 1], list[index]]
                }
            }
        })
    })
    return list
}